package com.buptse.utils;

import com.buptse.model.Information;

public class CarrierDecoder {
    enum CarrierCategory{
        _0("0","文字"),
        _1("1","图像"),
        _2("2","音频"),
        _3("3","视频"),
        _4("4","其他");

        private String code;
        private String description;
        //枚举的构造函数
        CarrierCategory(String code, String description) {
            this.code = code;
            this.description=description;;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String getInfoByCode(String code) {
            for (CarrierCategory carrierCategory : values()) {//获得每个键值对
                if (carrierCategory.getCode().equals(code)) {
                    return carrierCategory.getDescription();
                }
            }
            return "Code not found";
        }
    }
    public static void carrierDecode(String code, Information information){
        String carrierInformation= CarrierCategory.getInfoByCode(code);
        information.setCarrier(carrierInformation);
    }
}
